package com.chen.util;

import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONObject;
import com.chen.domain.Document;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

public class Test1 {

    public static void main(String[] args) {
        Document document = new Document();
        Map<String, Object> map = new HashMap<>();
        document.setDocumentId(1L);
        document.setCode("10010");
        document.setCreateTime(new Date());
        map = JSON.parseObject(JSON.toJSONString(document), Map.class);
        map.forEach((x, y) -> {
            System.out.println(x + "-------------->" + y);
        });

        map.clear();
        map.put("code", "10086");
        map.put("createTime", "2023-08-17 10:21:31");
        map.put("documentId", 1L);
        Document d = JSON.parseObject(JSON.toJSONString(map), Document.class);
        System.out.println(d);
    }
}
